home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / gcc_260.zip / gcc_260 / gcc.info-5 (.txt) < prev    next >
GNU Info File  |  1994-07-14  |  22KB  |  366 lines

  1. This is Info file gcc.info, produced by Makeinfo-1.54 from the input
  2. file gcc.texi.
  3.    This file documents the use and the internals of the GNU compiler.
  4.    Published by the Free Software Foundation 675 Massachusetts Avenue
  5. Cambridge, MA 02139 USA
  6.    Copyright (C) 1988, 1989, 1992, 1993 Free Software Foundation, Inc.
  7.    Permission is granted to make and distribute verbatim copies of this
  8. manual provided the copyright notice and this permission notice are
  9. preserved on all copies.
  10.    Permission is granted to copy and distribute modified versions of
  11. this manual under the conditions for verbatim copying, provided also
  12. that the sections entitled "GNU General Public License" and "Protect
  13. Your Freedom--Fight `Look And Feel'" are included exactly as in the
  14. original, and provided that the entire resulting derived work is
  15. distributed under the terms of a permission notice identical to this
  16.    Permission is granted to copy and distribute translations of this
  17. manual into another language, under the above conditions for modified
  18. versions, except that the sections entitled "GNU General Public
  19. License" and "Protect Your Freedom--Fight `Look And Feel'", and this
  20. permission notice, may be included in translations approved by the Free
  21. Software Foundation instead of in the original English.
  22. File: gcc.info,  Node: Installation,  Next: C Extensions,  Prev: Invoking GCC,  Up: Top
  23. Installing GNU CC
  24. *****************
  25. * Menu:
  26. * Configurations::    Configurations Supported by GNU CC.
  27. * Other Dir::     Compiling in a separate directory (not where the source is).
  28. * Cross-Compiler::   Building and installing a cross-compiler.
  29. * Sun Install::   See below for installation on the Sun.
  30. * VMS Install::   See below for installation on VMS.
  31. * Collect2::      How `collect2' works; how it finds `ld'.
  32. * Header Dirs::   Understanding the standard header file directories.
  33.    Here is the procedure for installing GNU CC on a Unix system.  See
  34. *Note VMS Install::, for VMS systems.  In this section we assume you
  35. compile in the same directory that contains the source files; see *Note
  36. Other Dir::, to find out how to compile in a separate directory on Unix
  37. systems.
  38.    You cannot install GNU C by itself on MSDOS; it will not compile
  39. under any MSDOS compiler except itself.  You need to get the complete
  40. compilation package DJGPP, which includes binaries as well as sources,
  41. and includes all the necessary compilation tools and libraries.
  42.   1. If you have built GNU CC previously in the same directory for a
  43.      different target machine, do `make distclean' to delete all files
  44.      that might be invalid.  One of the files this deletes is
  45.      `Makefile'; if `make distclean' complains that `Makefile' does not
  46.      exist, it probably means that the directory is already suitably
  47.      clean.
  48.   2. On a System V release 4 system, make sure `/usr/bin' precedes
  49.      `/usr/ucb' in `PATH'.  The `cc' command in `/usr/ucb' uses
  50.      libraries which have bugs.
  51.   3. Specify the host and target machine configurations.  You do this by
  52.      running the file `configure' with appropriate arguments.
  53.      The `configure' script searches subdirectories of the source
  54.      directory for other compilers that are to be integrated into GNU
  55.      CC.  The GNU compiler for C++, called G++ is in a subdirectory
  56.      named `cp'.  `configure' inserts rules into `Makefile' to build
  57.      all of those compilers.
  58.      If you are building a compiler to produce code for the machine it
  59.      runs on, specify the "configuration name" with the `--target'
  60.      option; the host will default to be the same as the target.  (If
  61.      you are building a cross-compiler, see *Note Cross-Compiler::.)
  62.      Here is an example:
  63.           ./configure --target=sparc-sun-sunos4.1
  64.      If you run `configure' without specifying configuration arguments,
  65.      `configure' tries to guess the type of host you are on, and uses
  66.      that configuration type for both host and target.  So you don't
  67.      need to specify a configuration, for building a native compiler,
  68.      unless `configure' cannot figure out what your configuration is.
  69.      A configuration name may be canonical or it may be more or less
  70.      abbreviated.
  71.      A canonical configuration name has three parts, separated by
  72.      dashes.  It looks like this: `CPU-COMPANY-SYSTEM'.  (The three
  73.      parts may themselves contain dashes; `configure' can figure out
  74.      which dashes serve which purpose.)  For example,
  75.      `m68k-sun-sunos4.1' specifies a Sun 3.
  76.      You can also replace parts of the configuration by nicknames or
  77.      aliases.  For example, `sun3' stands for `m68k-sun', so
  78.      `sun3-sunos4.1' is another way to specify a Sun 3.  You can also
  79.      use simply `sun3-sunos', since the version of SunOS is assumed by
  80.      default to be version 4.  `sun3-bsd' also works, since `configure'
  81.      knows that the only BSD variant on a Sun 3 is SunOS.
  82.      You can specify a version number after any of the system types,
  83.      and some of the CPU types.  In most cases, the version is
  84.      irrelevant, and will be ignored.  So you might as well specify the
  85.      version if you know it.
  86.      See *Note Configurations::, for a list of supported configuration
  87.      names and notes on many of the configurations.  You should check
  88.      the notes in that section before proceding any further with the
  89.      installation of GNU CC.
  90.      There are four additional options you can specify independently to
  91.      describe variant hardware and software configurations.  These are
  92.      `--with-gnu-as', `--with-gnu-ld', `--with-stabs' and `--nfp'.
  93.     `--with-gnu-as'
  94.           If you will use GNU CC with the GNU assembler (GAS), you
  95.           should declare this by using the `--with-gnu-as' option when
  96.           you run `configure'.
  97.           Using this option does not install GAS.  It only modifies the
  98.           output of GNU CC to work with GAS.  Building and installing
  99.           GAS is up to you.
  100.           Conversely, if you *do not* wish to use GAS and do not specify
  101.           `--with-gnu-as' when building GNU CC, it is up to you to make
  102.           sure that GAS is not installed.  GNU CC searches for a
  103.           program named `as' in various directories; if the program it
  104.           finds is GAS, then it runs GAS.  If you are not sure where
  105.           GNU CC finds the assembler it is using, try specifying `-v'
  106.           when you run it.
  107.           The systems where it makes a difference whether you use GAS
  108.           are
  109.           `hppa1.0-ANY-ANY', `hppa1.1-ANY-ANY', `i386-ANY-sysv',
  110.           `i386-ANY-isc',
  111.           `i860-ANY-bsd', `m68k-bull-sysv', `m68k-hp-hpux',
  112.           `m68k-sony-bsd',
  113.           `m68k-altos-sysv', `m68000-hp-hpux', `m68000-att-sysv', and
  114.           `mips-ANY').  On any other system, `--with-gnu-as' has no
  115.           effect.
  116.           On the systems listed above (except for the HP-PA and for ISC
  117.           on the 386), if you use GAS, you should also use the GNU
  118.           linker (and specify `--with-gnu-ld').
  119.     `--with-gnu-ld'
  120.           Specify the option `--with-gnu-ld' if you plan to use the GNU
  121.           linker with GNU CC.
  122.           This option does not cause the GNU linker to be installed; it
  123.           just modifies the behavior of GNU CC to work with the GNU
  124.           linker.  Specifically, it inhibits the installation of
  125.           `collect2', a program which otherwise serves as a front-end
  126.           for the system's linker on most configurations.
  127.     `--with-stabs'
  128.           On MIPS based systems and on Alphas, you must specify whether
  129.           you want GNU CC to create the normal ECOFF debugging format,
  130.           or to use BSD-style stabs passed through the ECOFF symbol
  131.           table.  The normal ECOFF debug format cannot fully handle
  132.           languages other than C.  BSD stabs format can handle other
  133.           languages, but it only works with the GNU debugger GDB.
  134.           Normally, GNU CC uses the ECOFF debugging format by default;
  135.           if you prefer BSD stabs, specify `--with-stabs' when you
  136.           configure GNU CC.
  137.           No matter which default you choose when you configure GNU CC,
  138.           the user can use the `-gcoff' and `-gstabs+' options to
  139.           specify explicitly the debug format for a particular
  140.           compilation.
  141.           `--with-stabs' is meaningful on the ISC system on the 386,
  142.           also, if `--with-gas' is used.  It selects use of stabs
  143.           debugging information embedded in COFF output.  This kind of
  144.           debugging information supports C++ well; ordinary COFF
  145.           debugging information does not.
  146.     `--nfp'
  147.           On certain systems, you must specify whether the machine has
  148.           a floating point unit.  These systems include
  149.           `m68k-sun-sunosN' and `m68k-isi-bsd'.  On any other system,
  150.           `--nfp' currently has no effect, though perhaps there are
  151.           other systems where it could usefully make a difference.
  152.      Here we spell out what files will be set up by `configure'.
  153.      Normally you need not be concerned with these files.
  154.         * A symbolic link named `config.h' is made to the top-level
  155.           config file for the machine you will run the compiler on
  156.           (*note Config::.).  This file is responsible for defining
  157.           information about the host machine.  It includes `tm.h'.
  158.           The top-level config file is located in the subdirectory
  159.           `config'.  Its name is always `xm-SOMETHING.h'; usually
  160.           `xm-MACHINE.h', but there are some exceptions.
  161.           If your system does not support symbolic links, you might
  162.           want to set up `config.h' to contain a `#include' command
  163.           which refers to the appropriate file.
  164.         * A symbolic link named `tconfig.h' is made to the top-level
  165.           config file for your target machine.  This is used for
  166.           compiling certain programs to run on that machine.
  167.         * A symbolic link named `tm.h' is made to the
  168.           machine-description macro file for your target machine.  It
  169.           should be in the subdirectory `config' and its name is often
  170.           `MACHINE.h'.
  171.         * A symbolic link named `md' will be made to the machine
  172.           description pattern file.  It should be in the `config'
  173.           subdirectory and its name should be `MACHINE.md'; but MACHINE
  174.           is often not the same as the name used in the `tm.h' file
  175.           because the `md' files are more general.
  176.         * A symbolic link named `aux-output.c' will be made to the
  177.           output subroutine file for your machine.  It should be in the
  178.           `config' subdirectory and its name should be `MACHINE.c'.
  179.         * The command file `configure' also constructs the file
  180.           `Makefile' by adding some text to the template file
  181.           `Makefile.in'.  The additional text comes from files in the
  182.           `config' directory, named `t-TARGET' and `x-HOST'.  If these
  183.           files do not exist, it means nothing needs to be added for a
  184.           given target or host.
  185.   4. The standard directory for installing GNU CC is `/usr/local/lib'.
  186.      If you want to install its files somewhere else, specify
  187.      `--prefix=DIR' when you run `configure'.  Here DIR is a directory
  188.      name to use instead of `/usr/local' for all purposes with one
  189.      exception: the directory `/usr/local/include' is searched for
  190.      header files no matter where you install the compiler.  To override
  191.      this name, use thge `--local-prefix' option below.
  192.   5. Specify `--local-prefix=DIR' if you want the compiler to search
  193.      directory `DIR/include' for header files *instead* of
  194.      `/usr/local/include'.  (This is for systems that have different
  195.      conventions for where to put site-specific things.)
  196.      Unless you have a convention other than `/usr/local' for
  197.      site-specific files, it is a bad idea to specify `--local-prefix'.
  198.   6. Make sure the Bison parser generator is installed.  (This is
  199.      unnecessary if the Bison output files `c-parse.c' and `cexp.c' are
  200.      more recent than `c-parse.y' and `cexp.y' and you do not plan to
  201.      change the `.y' files.)
  202.      Bison versions older than Sept 8, 1988 will produce incorrect
  203.      output for `c-parse.c'.
  204.   7. If you have chosen a configuration for GNU CC which requires other
  205.      GNU tools (such as GAS or the GNU linker) instead of the standard
  206.      system tools, install the required tools in the build directory
  207.      under the names `as', `ld' or whatever is appropriate.  This will
  208.      enable the compiler to find the proper tools for compilation of
  209.      the program `enquire'.
  210.      Alternatively, you can do subsequent compilation using a value of
  211.      the `PATH' environment variable such that the necessary GNU tools
  212.      come before the standard system tools.
  213.   8. Build the compiler.  Just type `make LANGUAGES=c' in the compiler
  214.      directory.
  215.      `LANGUAGES=c' specifies that only the C compiler should be
  216.      compiled.  The makefile normally builds compilers for all the
  217.      supported languages; currently, C, C++ and Objective C.  However,
  218.      C is the only language that is sure to work when you build with
  219.      other non-GNU C compilers.  In addition, building anything but C
  220.      at this stage is a waste of time.
  221.      In general, you can specify the languages to build by typing the
  222.      argument `LANGUAGES="LIST"', where LIST is one or more words from
  223.      the list `c', `c++', and `objective-c'.  If you have any
  224.      additional GNU compilers as subdirectories of the GNU CC source
  225.      directory, you may also specify their names in this list.
  226.      Ignore any warnings you may see about "statement not reached" in
  227.      `insn-emit.c'; they are normal.  Also, warnings about "unknown
  228.      escape sequence" are normal in `genopinit.c' and perhaps some
  229.      other files.  Likewise, you should ignore warnings about "constant
  230.      is so large that it is unsigned" in `insn-emit.c' and
  231.      `insn-recog.c'.  Any other compilation errors may represent bugs in
  232.      the port to your machine or operating system, and should be
  233.      investigated and reported (*note Bugs::.).
  234.      Some commercial compilers fail to compile GNU CC because they have
  235.      bugs or limitations.  For example, the Microsoft compiler is said
  236.      to run out of macro space.  Some Ultrix compilers run out of
  237.      expression space; then you need to break up the statement where
  238.      the problem happens.
  239.      If you are building with a previous GNU C compiler, do not use
  240.      `CC=gcc' on the make command or by editing the Makefile.  Instead,
  241.      use a full pathname to specify the compiler, such as
  242.      `CC=/usr/local/bin/gcc'.  This is because make might execute the
  243.      `gcc' in the current directory before all of the compiler
  244.      components have been built.
  245.   9. If you are building a cross-compiler, stop here.  *Note
  246.      Cross-Compiler::.
  247.  10. Move the first-stage object files and executables into a
  248.      subdirectory with this command:
  249.           make stage1
  250.      The files are moved into a subdirectory named `stage1'.  Once
  251.      installation is complete, you may wish to delete these files with
  252.      `rm -r stage1'.
  253.  11. If you have chosen a configuration for GNU CC which requires other
  254.      GNU tools (such as GAS or the GNU linker) instead of the standard
  255.      system tools, install the required tools in the `stage1'
  256.      subdirectory under the names `as', `ld' or whatever is
  257.      appropriate.  This will enable the stage 1 compiler to find the
  258.      proper tools in the following stage.
  259.      Alternatively, you can do subsequent compilation using a value of
  260.      the `PATH' environment variable such that the necessary GNU tools
  261.      come before the standard system tools.
  262.  12. Recompile the compiler with itself, with this command:
  263.           make CC="stage1/xgcc -Bstage1/" CFLAGS="-g -O"
  264.      This is called making the stage 2 compiler.
  265.      The command shown above builds compilers for all the supported
  266.      languages.  If you don't want them all, you can specify the
  267.      languages to build by typing the argument `LANGUAGES="LIST"'.  LIST
  268.      should contain one or more words from the list `c', `c++',
  269.      `objective-c', and `proto'.  Separate the words with spaces.
  270.      `proto' stands for the programs `protoize' and `unprotoize'; they
  271.      are not a separate language, but you use `LANGUAGES' to enable or
  272.      disable their installation.
  273.      If you are going to build the stage 3 compiler, then you might
  274.      want to build only the C language in stage 2.
  275.      Once you have built the stage 2 compiler, if you are short of disk
  276.      space, you can delete the subdirectory `stage1'.
  277.      On a 68000 or 68020 system lacking floating point hardware, unless
  278.      you have selected a `tm.h' file that expects by default that there
  279.      is no such hardware, do this instead:
  280.           make CC="stage1/xgcc -Bstage1/" CFLAGS="-g -O -msoft-float"
  281.  13. If you wish to test the compiler by compiling it with itself one
  282.      more time, install any other necessary GNU tools (such as GAS or
  283.      the GNU linker) in the `stage2' subdirectory as you did in the
  284.      `stage1' subdirectory, then do this:
  285.           make stage2
  286.           make CC="stage2/xgcc -Bstage2/" CFLAGS="-g -O"
  287.      This is called making the stage 3 compiler.  Aside from the `-B'
  288.      option, the compiler options should be the same as when you made
  289.      the stage 2 compiler.  But the `LANGUAGES' option need not be the
  290.      same.  The command shown above builds compilers for all the
  291.      supported languages; if you don't want them all, you can specify
  292.      the languages to build by typing the argument `LANGUAGES="LIST"',
  293.      as described above.
  294.      If you do not have to install any additional GNU tools, you may
  295.      use the command
  296.           make bootstrap LANGUAGES=LANGUAGE-LIST BOOT_CFLAGS=OPTION-LIST
  297.      instead of making `stage1', `stage2', and performing the two
  298.      compiler builds.
  299.  14. Then compare the latest object files with the stage 2 object
  300.      files--they ought to be identical, aside from time stamps (if any).
  301.      On some systems, meaningful comparison of object files is
  302.      impossible; they always appear "different."  This is currently
  303.      true on Solaris and probably on all systems that use ELF object
  304.      file format.  On some versions of Irix on SGI machines and OSF/1
  305.      on Alpha systems, you will not be able to compare the files
  306.      without specifying `-save-temps'; see the description of
  307.      individual systems above to see if you get comparison failures.
  308.      You may have similar problems on other systems.
  309.      Use this command to compare the files:
  310.           make compare
  311.      This will mention any object files that differ between stage 2 and
  312.      stage 3.  Any difference, no matter how innocuous, indicates that
  313.      the stage 2 compiler has compiled GNU CC incorrectly, and is
  314.      therefore a potentially serious bug which you should investigate
  315.      and report (*note Bugs::.).
  316.      If your system does not put time stamps in the object files, then
  317.      this is a faster way to compare them (using the Bourne shell):
  318.           for file in *.o; do
  319.           cmp $file stage2/$file
  320.           done
  321.      If you have built the compiler with the `-mno-mips-tfile' option on
  322.      MIPS machines, you will not be able to compare the files.
  323.  15. Build the Objective C library (if you have built the Objective C
  324.      compiler).  Here is the command to do this:
  325.           make objc-runtime CC="stage2/xgcc -Bstage2/" CFLAGS="-g -O"
  326.  16. Install the compiler driver, the compiler's passes and run-time
  327.      support with `make install'.  Use the same value for `CC',
  328.      `CFLAGS' and `LANGUAGES' that you used when compiling the files
  329.      that are being installed.  One reason this is necessary is that
  330.      some versions of Make have bugs and recompile files gratuitously
  331.      when you do this step.  If you use the same variable values, those
  332.      files will be recompiled properly.
  333.      For example, if you have built the stage 2 compiler, you can use
  334.      the following command:
  335.           make install CC="stage2/xgcc -Bstage2/" CFLAGS="-g -O" LANGUAGES="LIST"
  336.      This copies the files `cc1', `cpp' and `libgcc.a' to files `cc1',
  337.      `cpp' and `libgcc.a' in the directory
  338.      `/usr/local/lib/gcc-lib/TARGET/VERSION', which is where the
  339.      compiler driver program looks for them.  Here TARGET is the target
  340.      machine type specified when you ran `configure', and VERSION is
  341.      the version number of GNU CC.  This naming scheme permits various
  342.      versions and/or cross-compilers to coexist.
  343.      This also copies the driver program `xgcc' into
  344.      `/usr/local/bin/gcc', so that it appears in typical execution
  345.      search paths.
  346.      On some systems, this command causes recompilation of some files.
  347.      This is usually due to bugs in `make'.  You should either ignore
  348.      this problem, or use GNU Make.
  349.      *Warning: there is a bug in `alloca' in the Sun library.  To avoid
  350.      this bug, be sure to install the executables of GNU CC that were
  351.      compiled by GNU CC.  (That is, the executables from stage 2 or 3,
  352.      not stage 1.)  They use `alloca' as a built-in function and never
  353.      the one in the library.*
  354.      (It is usually better to install GNU CC executables from stage 2
  355.      or 3, since they usually run faster than the ones compiled with
  356.      some other compiler.)
  357.  17. Install the Objective C library (if you are installing the
  358.      Objective C compiler).  Here is the command to do this:
  359.           make install-libobjc CC="stage2/xgcc -Bstage2/" CFLAGS="-g -O"
  360.  18. If you're going to use C++, it's likely that you need to also
  361.      install the libg++ distribution.  It should be available from the
  362.      same place where you got the GNU C distribution.  Just as GNU C
  363.      does not distribute a C runtime library, it also does not include
  364.      a C++ run-time library.  All I/O functionality, special class
  365.      libraries, etc., are available in the libg++ distribution.
  366.